package step1;

public class Client {
    public final static int num = 10;

    public static void main(String[] args) throws InterruptedException {

        ///创建10个线程，模拟10个用户登录
        Thread[] threads = new Thread[num];
        for (int i = 0; i < num; i++) {
            Login login = new Login();
            login.setLoginname("" + String.format("%2s", (i + 1)) + "号用户");
            //创建了线程threads[i]，并把login对象（已实现Runnable接口）放入线程中
            threads[i]=new Thread(login);
            //线程状态转换为RUNNABLE
            threads[i].start();
        }
        for (Thread thread : threads) {
            //Client等待线程结束之后才能继续运行,防止最后一行的System.out.println提前运行
            thread.join();
        }
        System.out.println("网站共有"+Singleton.GetInstance().getCount()+"个用户登录");
    }
}
